<div class="modal-header">
  <div class="modal-title">{{ record.ID > 0 ? '编辑 ' + record.name + ' 信息' : '新建' }}</div>
</div>
<nz-spin *ngIf="!i" class="modal-spin"></nz-spin>
<div *ngIf="i">
  <form nz-form [formGroup]="validateForm">
    <input nz-input hidden formControlName="ID" />
    <div nz-row [nzGutter]="24">
      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="name">名称</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="名称必填！">
            <input nz-input formControlName="name" placeholder="权限名称" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="uri">请求uri</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请求uri必填！">
            <input nz-input formControlName="uri" placeholder="请求uri" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="method">请求方式</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请求方式必填！">
            <nz-select formControlName="method" nzPlaceHolder="请求方式">
              <nz-option nzValue="GET" nzLabel="GET（查看）"></nz-option>
              <nz-option nzValue="POST" nzLabel="POST（创建）"></nz-option>
              <nz-option nzValue="PUT" nzLabel="PUT（更新）"></nz-option>
              <nz-option nzValue="DELETE" nzLabel="DELETE（删除）"></nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzFor="group">所属组别</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <nz-select formControlName="group" nzMode="tags" nzPlaceHolder="所属组别" [nzMaxTagCount]="1" [nzMaxMultipleCount]="1">
              <nz-option *ngFor="let option of listOfGroupOption" [nzLabel]="option.label" [nzValue]="option.value"></nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzFor="desc">描述</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <textarea nz-input [rows]="3" placeholder="权限描述" formControlName="desc"></textarea>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzFor="super">超管权限</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <nz-radio-group formControlName="super">
              <label nz-radio [nzValue]="0">否</label>
              <label nz-radio [nzValue]="1">是</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>
  </form>
</div>

<div class="modal-footer">
  <button nz-button type="button" (click)="close()">关闭</button>
  <button
    nz-button
    type="submit"
    nzType="primary"
    (click)="save(validateForm.value)"
    [disabled]="!validateForm.valid"
    [nzLoading]="http.loading"
    >保存
  </button>
</div>
